class Ssp::UserSessionsController < Ssp::ApplicationController
  skip_before_action :authenticate!

  def show
    redirect_to new_ssp_user_session_path
  end

  def new
    @user_session = Ssp::UserSession.new
  end

  def create
    @user_session = Ssp::UserSession.new(user_session_params.to_h)

    if @user_session.save
      redirect_to ssp_root_path
    else
      render :new
    end
  end

  def destroy
    current_user_session.destroy
    redirect_to new_ssp_user_session_path
  end

  private

  def user_session_params
    params.require(:ssp_user_session).permit(:ssid, :password)
  end
end
